﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Windows;
using SWB = System.Windows.Browser;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Interactivity;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Dimok;

namespace MBC.UI {
	public class ShowImageFolder : TriggerAction<HyperlinkButton> {
		static SWB.HtmlWindow ImageFolderWindow;
		protected override void Invoke(object parameter) {
			var width = 800;
			var height = Convert.ToInt32(SWB.HtmlPage.Window.Eval("screen.availHeight"));
			var left = Convert.ToInt32(SWB.HtmlPage.Window.Eval("screen.availWidth")) - width;
			var url = this.AssociatedObject.Tag+"";
			if (ImageFolderWindow != null) {
				try {
					ImageFolderWindow.Invoke("setLocation", url);
					return;
				} catch(Exception exc) {
				}
			}
			ImageFolderWindow = SWB.HtmlPage.Window.Invoke("ShowModelessDialog", new Uri("/manager/ImageDialog.htm", UriKind.Relative),
				url,
				"dialogLeft:" + left + "px;dialogTop:0px;dialogHeight:" + height + "px;dialogWidth:" + width + "px;resizable:1;scroll:0") as SWB.HtmlWindow;
		}
	}
}
